/**
 * 
 */
package com.java.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.java.entity.Student;
import com.java.entity.Teacher;
import com.java.mapper.FunctionMapper;
import com.java.mapper.TeacherMapper;
import com.java.service.TeacherService;

/**
* @author Kidney
* 创建时间：2019年4月29日 下午6:13:35
* Description:
*/
/**
 * @author KIDNEY
 *
 */
@Service("TeacherSeriveImpl")
public class TeacherSeriveImpl implements TeacherService {

	@Autowired
	private TeacherMapper tm;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.java.service.TeacherService#getTeacherName(java.lang.Integer)
	 */
	@Override
	public String getTeacherName(Integer teacherId) {
		Teacher teacher = tm.selectByPrimaryKey(teacherId);

		return teacher.getUsername();
	}

	/* (non-Javadoc)
	 * @see com.java.service.TeacherService#getTeacher(java.lang.Integer)
	 */
	@Override
	public Teacher getTeacher(Integer teacherId) {
		// TODO Auto-generated method stub
		return tm.selectByPrimaryKey(teacherId);
	}

	/* (non-Javadoc)
	 * @see com.java.service.TeacherService#allTeacher()
	 */
	@Override
	public List<Teacher> allTeacher() {
		// TODO Auto-generated method stub
		return tm.getAll();
	}

	/* (non-Javadoc)
	 * @see com.java.service.TeacherService#insert(java.lang.String, java.lang.Integer, java.lang.String, java.lang.Integer, java.lang.String)
	 */
	@Override
	public Integer insert(String title, Integer collegeid, String degree, Integer userid, String username,Date birthYear,String sex) {
		// TODO Auto-generated method stub
		Teacher record = new Teacher();
		record.setCollegeid(collegeid);
		record.setTitle(title);
		record.setCollegeid(collegeid);
		record.setDegree(degree);
		record.setUserid(userid);
		record.setUsername(username);
		record.setSex(sex);
		int flag =tm.insertSelective(record);
		
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.java.service.TeacherService#delete(java.lang.Integer)
	 */
	@Override
	public Integer delete(Integer userid) {
		// TODO Auto-generated method stub
		
		 int flag= tm.deleteByPrimaryKey(userid);
		return flag;
	}

}
